
#import <QuartzCore/QuartZCore.h>
#import "ka-gles/kaGLESView.h"

@interface kaGLESView(PrivateMethods) 
- (void)createFrameBuffer;
- (void)destroyFrameBuffer;
@end

@implementation kaGLESView

- (id)initWithFrame:(CGRect)bounds withConfig:(const ka::GLESConfig *)config {
    
    self = [super initWithFrame:bounds];
    if (self) {
        CAEAGLLayer *eaglLayer = (CAEAGLLayer *)self.layer;
        eaglLayer.opaque = TRUE;
        eaglLayer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys:
                                        [NSNumber numberWithBool:FALSE], kEAGLDrawablePropertyRetainedBacking,
                                        kEAGLColorFormatRGBA8, kEAGLDrawablePropertyColorFormat,
                                        nil];
    }
    
    return self;
}

- (void)layoutSubviews {
    // The framebuffer will be re-created at the beginning of the next setFramebuffer method call.
    [self destroyFrameBuffer];
}

- (void)setEAGLContext:(EAGLContext *)context {
    if (context != _eaglContext) {
        [self destroyFrameBuffer];
        [_eaglContext release];
        [EAGLContext setCurrentContext:nil];
        _eaglContext = context;
    }
}

- (void)createFrameBuffer {
    
}

-(void)destroyFrameBuffer {
    
}

@end